package ${basePackage}.cli.command;

import ${basePackage}.generator.MainGenerator;
import ${basePackage}.model.DataModel;
import picocli.CommandLine;
import cn.hutool.core.bean.BeanUtil;
import picocli.CommandLine.Command;

import java.util.concurrent.Callable;
import lombok.Data;

/**
 * @author ${author}
 * @description 代码生成
 * @createDate ${createTime}
 */
@Command(name = "generate", description = "生成代码", mixinStandardHelpOptions = true)
@Data
public class GeneratorCommand implements Callable<Integer> {
<#list modelConfig.models as modelInfo>
    @CommandLine.Option(names = {<#if modelInfo.abbr??>"-${modelInfo.abbr}"</#if>, <#if modelInfo.fieldName??>"--${modelInfo.fieldName}"</#if>}, arity = "0..1", description = <#if modelInfo.description??>"${modelInfo.description}"</#if>, interactive = true, echo = true)
    private ${modelInfo.type} ${modelInfo.fieldName} <#if modelInfo.defaultValue??> = ${modelInfo.defaultValue?c}</#if>;
</#list>
    
    @Override
    public Integer call() throws Exception {
        DataModel dataModel = new DataModel();
        BeanUtil.copyProperties(this, dataModel);
        MainGenerator.doGenerator(dataModel);
        return 0;
    }
}